<template>

    <span>

    <slot :data="dictItems"></slot>

    </span>
    
</template>

<script>

    import persistentUtil from '@/common/persistentUtil.js'

    export default {
        props:[
            "dictIdent"
        ],

        name: "SystemDictData"

        ,
        data(){
            return {

                dictItems:[]

            };
        },
        mounted(){


            if(this.dictIdent){

                persistentUtil.getDictItems(this.dictIdent,s=>{

                    if(s){

                        this.dictItems = s;

                    }else{

                        this.loadRemote();
                    }


                },e=>{

                    this.loadRemote();

                });
            }

        } ,
        methods:{

            loadRemote(){

                this.$axios.get("/auth/dict/getDictItemListByDictIdent?dictIdent=" + this.dictIdent)
                    .then(d=>{

                        if(d.data.status === 0){

                            this.dictItems = d.data.data;

                            persistentUtil.saveDictItems(this.dictIdent,d.data.data);

                        }
                    },e=>{

                        //
                    })

            }
        }
    }
</script>

<style scoped>

</style>